<?php 
/*
 +----------------------------------------------------------------------
 | TEMMOKUMVC [ NO BEST, ONLY BETTER ]
 +----------------------------------------------------------------------
 | Copyright (c) 2018~2019 https://www.temmoku.cn All rights reserved.
 +----------------------------------------------------------------------
 | Author: 张宗强 Email:webmaster@temmoku.cn QQ:158726877 516669373 TEL:17895221001 微信:temmokumvc
 +---------------------------------------------------------------------- 
*/
namespace temmoku\lib;
class cookie {
	public static function set($key,$value,$day = '7',$domain=''){
		$key=strtolower($key);
		$time =  $day*24*60*60;
		if(!$domain){
			$domain=C('cookie_domain');
		}
		$key=C('cookie_is_en')=='1' ? 'temmoku_'.md5(C('MD5')."_".$key) : 'temmoku_'.$key;
		setcookie($key, $value, time() + $time, '/', $domain);
	}
	public static function get($key){
		$key=strtolower($key);
		$key=C('cookie_is_en')=='1' ? 'temmoku_'.md5(C('MD5')."_".$key) : 'temmoku_'.$key;
		return empty($_COOKIE[$key]) ? 0 : $_COOKIE[$key];
	}
	public static function del($key,$domain=''){
		$key=strtolower($key);
		$key=C('cookie_is_en')=='1' ? 'temmoku_'.md5(C('MD5')."_".$key) : 'temmoku_'.$key;
		if(!$domain){
			$domain=C('cookie_domain');
		}
		setcookie($key, '', '1262278861', '/', $domain);	
	}
}
?>